package com.example.mediamoudle.viewpage.fragment

import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.base.BaseFragment
import com.example.mediamoudle.R
import com.example.mediamoudle.databinding.FragmentViewpagerMediaBinding
import com.example.mediamoudle.router.MediaRouterPath

@Route(path = MediaRouterPath.MEDIA_VIEWPAGER_FRAGMENT)
class ViewPagerMediaFragment:BaseFragment<FragmentViewpagerMediaBinding>() {
    @JvmField
    @Autowired(name = MediaRouterPath.MEDIA_URL)
    var url:String =""


    @JvmField
    @Autowired(name = "position")
    var position = 0
    override fun getLayoutID(): Int= R.layout.fragment_viewpager_media

    override fun initView() {
        Log.i("TAGqw", "initView: $position")
      mBinding.mediaPlayer.setUp(url,true,"")
        mBinding.mediaPlayer.startPlayLogic()
    }

    override fun onResume() {
        super.onResume()
        Log.i("TAGqw", "onResume: $position")
        mBinding.mediaPlayer.startPlayLogic()
    }

    override fun onPause() {
        super.onPause()
        Log.i("TAGqw", "onPause: $position")
        mBinding.mediaPlayer.onVideoPause()
    }

    override fun onDestroy() {
        super.onDestroy()
        mBinding.mediaPlayer.release()
    }
}